<template>
	<!-- 申请退款 -->
	<view class="form-container">
		<nt-order-detail :orderInfo="commonForm.orderInfo"></nt-order-detail>
		<nt-card label="验券绑码">
			<view class="form-item horizontal">
				<view class="form-item__content">
					<u--input v-model="formData.code" placeholder="请输入券码"></u--input>
				</view>
			</view>
			<nt-button text="提交验券绑码" @tap="submit"></nt-button>
		</nt-card>
	</view>
</template>

<script>
	import {
		bindingMtCode
	} from "@/api"
	export default {
		data() {
			return {
				formData: {
					code: ''
				},
				loading: false
			}
		},
		inject: ["commonForm"],
		methods: {
			// 提交转单申请
			submit() {
				if(!this.formData.code) return this.toast('请输入券码')
				if(this.loading) return
				this.loading = true
				bindingMtCode(this.commonForm.options.id, this.formData.code).then(res => {
					if(res.code === 1) {
						this.toast('提交成功')
						setTimeout(() => this.back(), 1000)
					}
				}).catch(() => {
					this.loading = false
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	@import "./style.scss";

	/deep/ .button-container {
		margin-top: 60rpx;
	}
</style>